﻿<%@ CODEPAGE=65001 %>
<%
'///////////////////////////////////////////////////////////////////////////////
'// 插件应用:    Z-Blog 2.0 其它版本未知
'// 插件制作:    狼的旋律(http://www.wilf.cn) / zsx(http://www.zsxsoft.com)
'// 备    注:    相册分类查看
'// 最后修改:
'// 最后版本:
'///////////////////////////////////////////////////////////////////////////////
%>
<% Option Explicit %>
<% 'On Error Resume Next %>
<% Response.Charset="UTF-8" %>
<% Response.Buffer=True %>
<!-- #include file="../../c_option.asp" -->
<!-- #include file="../../../zb_system/function/c_function.asp" -->
<!-- #include file="../../../zb_system/function/c_system_lib.asp" -->
<!-- #include file="../../../zb_system/function/c_system_base.asp" -->
<!-- #include file="../../../zb_system/function/c_system_plugin.asp" -->
<!-- #include file="../../plugin/p_config.asp" -->
<%
Call System_Initialize()
Call WindsPhoto_Initialize()

If CheckpluginState("windsphoto") = False Then Call ShowError(48)

Dim typeid,albumname,hot,js,ps,mo,rs,sql,pss,temprs,sm,i,a,b,url,surl,innerHtml
If IsNumeric(Request.QueryString("typeid")) = False Then
    Response.Redirect "default.asp"
Else
    typeid = CInt(Request.QueryString("typeid"))
End If
If Request.QueryString("mo") <>"" And IsNumeric(Request.QueryString("mo")) = False Then
    Response.Redirect "default.asp"
Else
	If Request.QueryString("mo") <>"" Then mo = CInt(Request.QueryString("mo"))
End If

sql = "select * FROM WindsPhoto_zhuanti where id="&typeid
Set Rs = Server.CreateObject("ADODB.Recordset")
Rs.Open sql, objConn, 1, 3
If Rs.EOF Or Rs.bof Then
    Response.Redirect "default.asp"
End If
'获取浏览模式，如果url参数没有指定，则读取设置
If mo = "" Then mo = Rs("view")
albumname = Rs("name")
js = Rs("js")
hot = Rs("hot")
ps = Rs("pass")
If hot = "" Or IsNull(hot) = True Then
    Rs("hot") = "1"
Else
    If BlogUser.Level>2 Then Rs("hot") = hot + 1
End If
Rs.update
Rs.Close
Set Rs = Nothing
%>

<%
Function Lightbox_Code
    innerHtml = ""
    innerHtml = innerHtml & "<link rel=""stylesheet"" href="""& WP_SUB_DOMAIN &"script/lightbox/lightbox.css"" type=""text/css"" media=""screen"" />" & VBCRLF
    innerHtml = innerHtml & "<script type=""text/javascript"" src="""& WP_SUB_DOMAIN &"script/lightbox/lightbox.min.js""></script>" & VBCRLF
    Lightbox_Code = innerHtml
End Function

Function fancyBox_Code
    innerHtml = ""
    innerHtml = innerHtml & "<link rel=""stylesheet"" href="""& WP_SUB_DOMAIN &"script/fancybox/jquery.fancybox.css"" type=""text/css"" media=""screen"" />" & VBCRLF
    innerHtml = innerHtml & "<script type=""text/javascript"" src="""& WP_SUB_DOMAIN &"script/fancybox/jquery.fancybox.pack.js""></script>" & VBCRLF
	innerHtml = innerHtml & "<script type=""text/javascript"" src="""& WP_SUB_DOMAIN &"script/fancybox/fancybox.config.js""></script>" & VBCRLF
    fancyBox_Code = innerHtml
End Function

Function HighSlide_Code
    innerHtml = ""
    innerHtml = innerHtml & "<link rel=""stylesheet"" href="""& WP_SUB_DOMAIN &"script/highslide/highslide.css"" type=""text/css"" media=""screen"" />" & VBCRLF
    innerHtml = innerHtml & "<script type=""text/javascript"" src="""& WP_SUB_DOMAIN &"script/highslide/highslide.packed.js""></script>" & VBCRLF
    innerHtml = innerHtml & "<script type=""text/javascript"" src="""& WP_SUB_DOMAIN &"script/highslide/highslide2.js""></script>" & VBCRLF
    HighSlide_Code = innerHtml
End Function

Function Gallery_Style
    innerHtml = ""
    If WP_SCRIPT_TYPE = "1" Then
        innerHtml = innerHtml & "rel='class='highslide' onclick='return hs.expand(this)'"
	ElseIf WP_SCRIPT_TYPE = "2" Then
        innerHtml = innerHtml & "rel='lightbox[WindsPhoto]'"
    ElseIf WP_SCRIPT_TYPE = "3" Then
        innerHtml = innerHtml & "class='fancybox' rel='WindsPhoto'"
    End If
    Gallery_Style = innerHtml
End Function

Function GetPhoto()

    '判断是否需要密码
    pss = Request.cookies("WindsPhoto"&typeid)
    If Len(ps)>0 Then
        If pss<>ps Then
            GetPhoto = GetPhoto&"<div><span style='color:#808000;font-size:14px;'>该相册为加密相册，如果你有密码的话，请提供查看密码：</a></span><form name='form' method='post' action='pass.asp?typeid="&typeid&"'><input type='password' name='pase'><input type='submit' name='Submit' value='确定'></form></div>"
            Exit Function
        End If
    End If
    '取得相册图片数量
	Set temprs=objConn.Execute("select count(*) as C FROM WindsPhoto_desktop where zhuanti="&typeid)
	sm = temprs("C")
    GetPhoto = GetPhoto&"<div class=""wp_album_info""><span style=""float:left;"">"&sm&"张照片 | "&hot&"次浏览</span><span style=""float:right;"">浏览方式：<a href='?typeid="&typeid&"&mo=0'>缩略图</a> • <a href='?typeid="&typeid&"&mo=2'>瀑布流</a> • <a href='?typeid="&typeid&"&mo=1'>列表</a></span><div style=""clear:both;""></div></div>"& VBCRLF
    '介绍
    If js<>"" Then
        GetPhoto = GetPhoto&"<div class=""wp_album_intro"">"&js&"</div>"& VBCRLF
    End If
    '相片
    Dim ipagecount,ipagecurrent,irecordsshown
    If request.querystring("page") = "" Then
        ipagecurrent = 1
    Else
        ipagecurrent = CInt(request.querystring("page"))
    End If
    If mo=0 Then
        GetPhoto = GetPhoto&"<table width=""100%"" border=""0"" cellspacing=""0"" cellpadding=""5"">"& VBCRLF
        If WP_ORDER_BY = "0" Then
            sql = "SELECT * FROM WindsPhoto_desktop where zhuanti="&typeid&" ORDER BY id asc"
        Else
            sql = "SELECT * FROM WindsPhoto_desktop where zhuanti="&typeid&" ORDER BY id desc"
        End If
        Set rs = Server.CreateObject("ADODB.Recordset")
        rs.Open sql, objConn, 1, 1
        rs.pagesize = WP_SMALL_PAGERCOUNT
        ipagecount = rs.pagecount
        If ipagecurrent > ipagecount Then ipagecurrent = ipagecount End If
        If ipagecurrent < 1 Then ipagecurrent = 1 End If
        If ipagecount = 0 Then
            GetPhoto = GetPhoto&"<tr><td align=""center""><img src=""images/nopic.jpg"" /></tr></td>"& VBCRLF
        Else
            rs.absolutepage = ipagecurrent
            irecordsshown = 0
            Do While irecordsshown<WP_SMALL_PAGERCOUNT And Not rs.EOF
                GetPhoto = GetPhoto&"<tr align=""center"">"& VBCRLF
				For i = 1 To 3
					If Not rs.EOF Then
						surl = rs("surl")
						url = rs("url")
						If Left(surl, 4)<>"http" Then surl = WP_SUB_DOMAIN & surl
						If Left(url, 4)<>"http" Then url = WP_SUB_DOMAIN & url
						If WP_SCRIPT_TYPE = "4" Then url = WP_SUB_DOMAIN & "display.asp?id="&rs("id")
						GetPhoto = GetPhoto&"<td width=""33%""><a href="""&url&""" "& Gallery_Style &" title="""&rs("name")&"""><img class=""wp_small"" src="""&surl&"""  alt="""&rs("name")&""" /></a><br />"&rs("name")&"</td>"& VBCRLF
						irecordsshown = irecordsshown + 1
						rs.movenext
					End If
				Next
                GetPhoto = GetPhoto&"</tr>"
            Loop
        End If
        GetPhoto = GetPhoto&"</table>"& VBCRLF

    ElseIf mo=1 Then

        If WP_ORDER_BY = "0" Then
            sql = "SELECT * FROM WindsPhoto_desktop where zhuanti="&typeid&" ORDER BY id asc"
        Else
            sql = "SELECT * FROM WindsPhoto_desktop where zhuanti="&typeid&" ORDER BY id desc"
        End If
        Set rs = Server.CreateObject("ADODB.Recordset")
        rs.Open sql, objConn, 1, 1
        rs.pagesize = WP_LIST_PAGERCOUNT
        ipagecount = rs.pagecount
        If ipagecurrent > ipagecount Then ipagecurrent = ipagecount End If
        If ipagecurrent < 1 Then ipagecurrent = 1 End If
        If ipagecount = 0 Then
            GetPhoto = GetPhoto&"<p align=""center""><img src=""images/nopic.jpg"" /></p>"& VBCRLF
        Else
            rs.absolutepage = ipagecurrent
            irecordsshown = 0
            Do While irecordsshown<WP_LIST_PAGERCOUNT And Not rs.EOF
                surl = rs("surl")
				url = rs("url")
				If Left(url, 4)<>"http" Then
					surl = WP_SUB_DOMAIN & url
					url = WP_SUB_DOMAIN & url
				End If
				If WP_SCRIPT_TYPE = "4" Then url = WP_SUB_DOMAIN & "display.asp?id="&rs("id")
                GetPhoto = GetPhoto&"<p align=""center""><a href="""&url&""" " & Gallery_Style &" title="""&rs("name")&"""><img class=""wp_list"" alt="""&rs("name")&""" src="""&surl&""" /></a><br />"&rs("name")&"</p>"& VBCRLF
                irecordsshown = irecordsshown + 1
                rs.movenext
            Loop
        End If

	'瀑布流模式
	ElseIf mo=2 Then

        If WP_ORDER_BY = "0" Then
            sql = "SELECT * FROM WindsPhoto_desktop where zhuanti="&typeid&" ORDER BY id asc"
        Else
            sql = "SELECT * FROM WindsPhoto_desktop where zhuanti="&typeid&" ORDER BY id desc"
        End If
        Set rs = Server.CreateObject("ADODB.Recordset")
        rs.Open sql, objConn, 1, 1
        rs.pagesize = WP_SMALL_PAGERCOUNT*2
        ipagecount = rs.pagecount
        If ipagecurrent > ipagecount Then ipagecurrent = ipagecount End If
        If ipagecurrent < 1 Then ipagecurrent = 1 End If
        If ipagecount = 0 Then
            GetPhoto = GetPhoto & "<p align=""center""><img src=""images/nopic.jpg"" /></p>"& VBCRLF
        Else
            rs.absolutepage = ipagecurrent
            irecordsshown = 0
			GetPhoto = GetPhoto & "<div id=""wp_waterfall"">"
            Do While irecordsshown<WP_SMALL_PAGERCOUNT*2 And Not rs.EOF
				surl = rs("surl")
				url = rs("url")
				If Left(surl, 4)<>"http" Then surl = WP_SUB_DOMAIN & surl
				If Left(url, 4)<>"http" Then url = WP_SUB_DOMAIN & url
				If WP_WATERFLOW_WIDTH>(WP_SMALL_WIDTH*1.5) Then surl = url
				If WP_SCRIPT_TYPE = "4" Then url = "display.asp?id="&rs("id")
                GetPhoto = GetPhoto & "<div class=""wp_waterfall""><a href="""&url&""" " & Gallery_Style &" title="""&rs("name")&"""><img alt="""&rs("name")&""" src="""&surl&""" /></a></div>"& VBCRLF
                irecordsshown = irecordsshown + 1
                rs.movenext
            Loop
			GetPhoto = GetPhoto & "</div>"& VBCRLF
			GetPhoto = GetPhoto & "<style>#wp_waterfall img{width:"&WP_WATERFLOW_WIDTH&"px;}</style>"& VBCRLF
			GetPhoto = GetPhoto & "<script type=""text/javascript"" src=""script/jquery.masonry.min.js""></script>"& VBCRLF
			GetPhoto = GetPhoto & "<script type=""text/javascript"" src=""script/masonry.config.js""></script>"& VBCRLF
        End If

    End If

	'分页
	If ipagecount >1 Then
		GetPhoto = GetPhoto&"<div class=""post pagebar"">"
		GetPhoto = GetPhoto&"<a title=""首页"" href=""?typeid="&typeid&"&mo="&mo&"&page=1""><span class=""page first-page"">1</span></a>"
		If ipagecurrent = 1 Then
			GetPhoto = GetPhoto&"<span class=""page other-page"">«</span>"
		Else
			GetPhoto = GetPhoto&"<a title=""上一页"" href=""?typeid="&typeid&"&mo="&mo&"&page="&ipagecurrent -1&"""><span class=""page"">«</span></a>"
		End If

		If ipagecount>ZC_PAGEBAR_COUNT Then
			a=ipagecurrent-Cint((ZC_PAGEBAR_COUNT-1)/2)
			b=ipagecurrent+ZC_PAGEBAR_COUNT-Cint((ZC_PAGEBAR_COUNT-1)/2)-1
			If a<=1 Then
				a=1:b=ZC_PAGEBAR_COUNT
			End If
			If b>=ipagecount Then
				b=ipagecount:a=ipagecount-ZC_PAGEBAR_COUNT+1
			End If
		Else
			a=1:b=ipagecount
		End If

		For i = a to b
			If ipagecurrent = i Then
				GetPhoto=GetPhoto&"<span class=""page now-page"">"&i&"</span>"
			Else
				GetPhoto=GetPhoto&"<a href=""?typeid="&typeid&"&mo="&mo&"&page="&i&"""><span class=""page"">"&i&"</span></a>"
			End If
		Next

		If ipagecount>ipagecurrent Then
			GetPhoto = GetPhoto&"<a title=""下一页"" href=""?typeid="&typeid&"&mo="&mo&"&page="&ipagecurrent + 1&"""><span class=""page"">»</span></a>"
		Else
			GetPhoto = GetPhoto&"<span class=""page other-page"">»</span>"
		End If

		GetPhoto = GetPhoto&"<a title=""尾页"" href=""?typeid="&typeid&"&mo="&mo&"&page="&ipagecount&"""><span class=""page last-page"">"&ipagecount&"</span></a></div>"
	End If
	'rs.Close
	Set rs = Nothing

End Function
%>

<%
Dim objArticle
Set objArticle = New TArticle
objArticle.FType=ZC_POST_TYPE_PAGE
If GetTemplate("TEMPLATE_WP_ALBUM")<>empty Then objArticle.template = "WP_ALBUM"
'objArticle.Title = WP_ALBUM_NAME &"-"& albumname
objArticle.Title = albumname
objArticle.Content = GetPhoto()
If objArticle.Export(ZC_DISPLAY_MODE_SYSTEMPAGE) Then
	objArticle.Build
    Dim Html,AddedHtml
    Html = objArticle.html
	AddedHtml="<link rel=""alternate"" type=""application/rss+xml"" href="""& WP_SUB_DOMAIN &"rss.asp?id="&typeid&""" title=""订阅我的相册"" />" & vbCrLf
	AddedHtml = AddedHtml & "<link rel=""stylesheet"" href="""& WP_SUB_DOMAIN &"images/windsphoto.css"" type=""text/css"" media=""screen"" />" & VBCRLF
	AddedHtml = AddedHtml & "<style type=""text/css"">img.wp_top,img.wp_small{max-width:"& WP_SMALL_WIDTH &"px !important;max-height:"& WP_SMALL_HEIGHT &"px;}img.wp_list{max-width:"& WP_LIST_WIDTH &"px;}</style>" & VBCRLF & "</head>"

    If WP_SCRIPT_TYPE = "1" Then
        Html = Replace(Html, "</head>", HighSlide_Code & AddedHtml)
    ElseIf WP_SCRIPT_TYPE = "2" Then
        Html = Replace(Html, "</head>", Lightbox_Code & AddedHtml)
    ElseIf WP_SCRIPT_TYPE = "3" Then
        Html = Replace(Html, "</head>", fancyBox_Code & AddedHtml)
    Else
        Html = Replace(Html, "</head>", AddedHtml)
    End If

	Html = Replace(Html, "short_name:""wolfit""", "short_name:""windsphoto""")
    Html = Replace(Html, ">Powered By", ">Powered By <a href=""http://www.windsphoto.com"" target=""_blank"" title=""WindsPhoto官方网站"">WindsPhoto</a> &amp;")
    Call ClearGlobeCache
    Call LoadGlobeCache
    Response.Write Html
End If
Set objArticle = Nothing
%>

<%
Call System_Terminate()

If Err.Number<>0 Then
	Call ShowError(0)
End If
%>